package com.sino.tb.secMgr;

import java.sql.*;
import java.util.*;
import xpubbean.Db.*;

public class User {
	private String username;
	private int loginNum;
	private String password;
	private String userCode;
	private long areaID;
	private long departmentID;
	private long userID;

	public User() {
	}

	public long getUserID() {
		return userID;
	}

	public void setUserID(long userID) {
		this.userID = userID;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public int getLoginNum() {
		return loginNum;
	}

	public void setLoginNum(int loginNum) {
		this.loginNum = loginNum;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public SystemFunction[] getFunctionList() {
		Connection con = null;
		xpubbean.Db.Conn conn = new Conn();
		con = conn.getConnection();

		//conn = null;
		SystemFunction[] result = null;
		ArrayList temp = new ArrayList();
		String sql = "SELECT  * " +
					 "FROM    v_user_function_power " +
					 "WHERE   c_user_id =  AND " +
					 "        length(c_objid) <= 5 " +
					 "ORDER BY to_char(c_objid) ";
		try {
			Statement stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery(sql);
			while (rs.next()) {
				SystemFunction sf = new SystemFunction();
				sf.setCode(rs.getString("c_objid"));
				sf.setName("c_function_name");
				sf.setLink("c_function_link");
				temp.add(sf);
			}
			rs.close();
			stmt.close();
			rs = null;
			stmt = null;
			result = new SystemFunction[temp.size()];
			Iterator values = temp.listIterator();
			int i = 0;
			while (values.hasNext()) {
				result[i++] = (SystemFunction) values.next();
			}
		} catch (Exception e) {
		} finally {
			try {
				con.close();
			} catch (Exception e) {

			}
		}
		return result;

	}

	public String getMD5(String password) {
		MD5 md5 = new MD5();
		return md5.calcMD5(password).trim();
	}

	public String getUserCode() {
		return userCode;
	}

	public void setUserCode(String userCode) {
		this.userCode = userCode;
	}

	public long getDepartmentID() {
		return departmentID;
	}

	public void setDepartmentID(long departmentID) {
		this.departmentID = departmentID;
	}

	public long getAreaID() {
		return areaID;
	}

	public void setAreaID(long areaID) {
		this.areaID = areaID;
	}

}
